package cn.echase.ecare.yinfayun.service.impl;

import cn.echase.ecare.yinfayun.domain.dto.GetAssessInfoReqDto;
import cn.echase.ecare.yinfayun.domain.entity.AssessInfoResult;
import cn.echase.ecare.yinfayun.domain.mapper.AssessInfoResultMapper;
import cn.echase.ecare.yinfayun.service.IAssessInfoResultService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import static cn.echase.ecare.yinfayun.constants.AssessConstant.IS_DELETED.UN_DELETED;

/**
 * 评估信息结果表(AssessInfoResult)表服务实现类
 *
 * @author hanpeng
 * @date 2024-09-30 14:23:12
 */
@Service("assessInfoResultService")
public class AssessInfoResultServiceImpl extends ServiceImpl<AssessInfoResultMapper, AssessInfoResult> implements IAssessInfoResultService {

    @Override
    public AssessInfoResult getAssessInfoResult(GetAssessInfoReqDto reqDto) {
        LambdaQueryWrapper<AssessInfoResult> resultLambdaQueryWrapper = Wrappers.lambdaQuery();
        resultLambdaQueryWrapper.eq(StrUtil.isNotBlank(reqDto.getTenantId()), AssessInfoResult::getTenantId, reqDto.getTenantId());
        resultLambdaQueryWrapper.eq(StrUtil.isNotBlank(reqDto.getAssessNo()), AssessInfoResult::getAssessNo, reqDto.getAssessNo());
        resultLambdaQueryWrapper.eq(StrUtil.isNotBlank(reqDto.getTemplateId()), AssessInfoResult::getTemplateId, reqDto.getTemplateId());
        resultLambdaQueryWrapper.eq(AssessInfoResult::getDeleted, UN_DELETED);
        return this.getOne(resultLambdaQueryWrapper);
    }
}
